﻿using Caliburn.Micro;
using myapp.Events;
using myapp.Events.ViewModel;
using myapp.Instances;
using myappcore.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myapp.ViewModels
{
    /// <summary>
    /// Item Manager ViewModel
    /// </summary>
    public class ItemManagerViewModel : IBaseContentViewModel
    {
        #region Attribute
        private static ItemManagerViewModel _instance;
        #endregion

        #region Properties

        /// <summary>
        /// Item Group List View Model
        /// </summary>
        public Screen ItemGroupView { get; set; }

        /// <summary>
        /// Item List View Model
        /// </summary>
        public Screen ItemView { get; set; }

        /// <summary>
        /// Instance of ItemManagerViewModel
        /// </summary>
        public static ItemManagerViewModel Instance
        {
            get
            {
                if (null == _instance)
                {
                    _instance = new ItemManagerViewModel();
                }
                return _instance;
            }
        }
        #endregion

        #region Constructure
        /// <summary>
        /// Constructor ItemManagerViewModel
        /// </summary>
        private ItemManagerViewModel()
        {
            DisplayName = "Quản Lí Bán Hàng";
            ItemGroupView = ItemGroupListViewModel.Instance;
            ItemView = ItemListViewModel.Instance;
            var lst = ItemGroupListViewModel.Instance.ItemGroupViewList.ToList();
            if (lst.Count > 0)
            {
                MainInstance.Instance.EventAggregator.Publish(new ViewModelItemGroupSelectedEvent()
                {
                    ItemGroupViewModel = lst[0]
                });
            }

        }
        #endregion

        #region Method

        #endregion
    }
}
